<?xml version="1.0" encoding="ISO-8859-1" ?>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@page import="java.util.Iterator"%>
<%@page import="net.groupme.model.ObjectFactory"%>
<%@page import="org.groupme.contextsearch.evaluation.ContextBasedSearchEvaluation"%>
<%@page import="org.groupme.contextsearch.ContextSearch"%>
<%@page import="java.util.List"%>
<%@page import="net.groupme.search.strategy.model.WeightedUser"%>
<%@page import="org.groupme.contextsearch.evaluation.model.UserEvaluation"%>
<%@page import="net.groupme.model.Tag"%>
<%@page import="org.groupme.contextsearch.evaluation.model.SearchSetting"%>
<%@page import="org.groupme.contextsearch.model.SearchContextType"%>
<%@page import="org.groupme.contextsearch.evaluation.io.ReadWriteDBUtility"%>
<%@page import="org.groupme.contextsearch.SearchContextFactory"%>
<%@page import="java.util.Map"%>
<%@page import="java.util.HashMap"%>
<%@page import="net.groupme.search.strategy.model.WeightedTag"%>
<%@page import="net.groupme.search.strategy.model.WeightedResource"%>
<%@page import="org.groupme.contextsearch.evaluation.ParticipantIncentives"%>
<%@page import="java.util.ArrayList"%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<!-- meta tags, link to css:  -->
	<%@ include file="../jsp-includes/mymetaheader.jsp" %>
	
	<!--  Ajax-Includes -->
    <script type='text/javascript' src='/GroupMe/dwr/interface/DWRUserManager.js'></script>
    <script type='text/javascript' src='/GroupMe/dwr/interface/DWRContextSearchEvaluationManager.js'></script>
    <script type='text/javascript' src='/GroupMe/dwr/engine.js'></script>
    <script type='text/javascript' src='/GroupMe/dwr/util.js'></script>
    <script type="text/javascript" src="<%= request.getContextPath()%>/highslide/highslide.js"></script>
	
	<!-- Prototype-Include -->
	<script src="<%= request.getContextPath()%>/scriptaculous/prototype.js" type="text/javascript"></script>
	<script src="<%= request.getContextPath()%>/scriptaculous/scriptaculous.js" type="text/javascript"></script>

	
	<script type="text/javascript">   
	    hs.graphicsDir = '<%= request.getContextPath()%>/highslide/graphics/';
	    hs.outlineType = 'rounded-white';
	    hs.outlineWhileAnimating = true;
	    hs.allowMultipleInstances = false;
	    hs.marginRight = 50;
	    
	    
	    function preview(website) {
		return hs.htmlExpand(this, { src: website, contentId: 'htmlPrev', objectType: 'iframe'});
		}
	</script>
	
	<title>Welcome to GroupMe! - The Social Semantic Web</title>
	
	<!-- setting initial tag-cloud height -->
	<script type="text/javascript">
	/*This funtion sets the height of the tag-cloud to the (almost) same size as the group-list*/
		function setTagCloudSize(){
			var groupListHeight = $('main_home').getHeight();
			var userListHeight = $('latestUsers').getHeight();
			var tagCloudHeightSize = groupListHeight - userListHeight;
			var tagCloudHeight = tagCloudHeightSize + "px";
			$('tagCloud_content').setStyle({
				height: tagCloudHeight,
			});
		}
		
		
		function showCompleteTagCloud(){
			DWRSearchManager.getCompleteTagCloud(showCompleteTagCloudCallback);
			$('main_home_content').hide();
			$('user_groups').setStyle({paddingBottom: '9px'});
			$('completeTagcloud_content').show();
			$('completeTagcloud_content').innerHTML += "<img src=\"<%= request.getContextPath() + RENDERING_CONSTANTS.RELATIVE_PATH_OF_AJAX_LOADING_IMAGE %>\"/> " +
					"<small><i>Computing the tag cloud.</i></small>";
		}
		
		/**
		 * Visualize the complete groupme tag cloud.
		 */
		 function showCompleteTagCloudCallback(tagCloud){
		 	if(tagCloud == null || tagCloud.html == ""){
		 		$('completeTagcloud_content').innerHTML = "<i>Sorry, there is a problem with computing the tag cloud. Try it again</i>";
		 	}else{
		 		$('completeTagcloud_content').innerHTML = tagCloud.html;
		 		$('completeTagcloud_content').show();
				}
			}
		<% if(userManager.getUser() != null){ %>		
		/**
		 * The participant rated a user: Store the rating.
		 */		
		function storeUserRating(userId, rating, setting){
			DWRContextSearchEvaluationManager.storeUserRating('<%= userManager.getUser().getId() %>', userId, rating, setting, stored);
		}
		/**
		 * The participant rated a tag: Store the rating.
		 */		
		function storeTagRating(tagId, rating, setting){
			DWRContextSearchEvaluationManager.storeTagRating('<%= userManager.getUser().getId() %>', tagId, rating, setting, stored);
		}
		/**
		 * The participant rated a resource: Store the rating.
		 */		
		function storeResourceRating(resourceId, rating, setting){
			DWRContextSearchEvaluationManager.storeResourceRating('<%= userManager.getUser().getId() %>', resourceId, rating, setting, stored);
		}	
		
		function stored(resultMessage){
			//do something
		}
		<% } %>
		//init stuff:		
	function init() {
		DWRUtil.useLoadingMessage();
		
	}
	</script>
	
	<style type="text/css" media="screen">
				
			/* put the left rounded edge on the track */
			.slider-track-left {
				position: absolute;
				width: 5px;
				height: 9px;
				background: transparent url(./images/slider-images-track-left.png) no-repeat top left;
			}
			
			/* put the track and the right rounded edge on the track */
			.slider-track {
				background: transparent url(./images/slider-images-track-right.png) no-repeat top right;
			}
			
			td {
				padding: 4px;
				margin: 4px;
				vertical-align: top;
				
				border: thin;
				border-style: dotted;
				border-color: gray;
			}
		</style>
	
</head>
<body onload="init();">
	<!-- title image, logo:  -->
	<div id="groupme_header">
		<%@ include file="../jsp-includes/groupme_header.jsp" %>
	</div>
	
	<!-- Menu: -->
	<div id="menu">
		<%@ include file="../jsp-includes/groupme_menu.jsp" %>
	</div>
	<!-- content and sidebar -->
	<!-- Content: -->
	<div id="mycontent">
		<div id="welcome" style="text-align: center;  margin-bottom: 1em; color: #ccc;  font-size: small;">
				Welcome to the GroupMe! Context Search User Study 
		</div>
		<div id="main_home" style="font-size: small; ">
		
			<% if(userManager.getUser() == null){ %>
				Please login with your GroupMe! user account. 
			<%} else { %>
		<h1>Welcome to the Study!</h1>
		<br/>
		Hi <%= userManager.getUser().getFirstName() %>,<br/><br/>
		thank you for participating in this user study! <br/><br/>
		What you should do: Given a set of items (= users, tags, or resources), you should rate for each of these items:
		<ol>
			<li><strong>relevance to query:</strong> Is the given item relevant to the query? That means, if you would submit the 
			query would you then expect the entity in the <i>result set</i> (= items relevant to the query)?<br/></li>
			<li><strong>relevance to context:</strong> The context can be a (1) group, (2) resource, or (3) user. You should judge whether the given item is relevant to the context.
			For the different types of context this means: <br/><br/>
			(1) Does the item fit to (the topic of) a group (= context)? <br/>
			(2) Does the item and the resource (=context) somehow fit together? <br/>
			(3) Does the item and the user (= context) somehow fit together?</li>
		</ol>
		<br/><br/>
		<strong>Practical issues:</strong>
		<ul>
			<li>Explanatory video: <a href="http://groupme.org/videos/study-german.swf">screencast video</a> (german)</li>
			<li>When you move the sliders you will see what each position means. We differentiate between: "I don't know", "no" (= not relevant), "rather no", "rather yes", and "yes" (= relevant). </li>
			<li>Please, use "I don't know" as seldom as possible.</li>
			<li>Clicking on the links (e.g. of the items in the left column) opens an item in a new "preview browser window". Clicking on other links will open the items in the same "preview browser window".</li>
			<li>Recommendation: Move the "preview browser window" to your second screen (if you have) so that the rating window is on the one screen and the preview window is on the other screen.</li>
			<li>Clicking on "preview" opens an item in a java-script window.</li>
			<li><strong>Beer:</strong> For each rating (different from "I don't know") you get credit which are converted to real beers, which I will spend you for your help!</li>			
		</ul>
		<br/><br/>
		<%	List<Tag> personalList = ContextBasedSearchEvaluation.getTagsForParticipant(userManager.getUser());
						if(!personalList.isEmpty()){%>
						Queries especially assigned to you: 
						<%for(Tag tag: personalList){ %>
						<br/>- <a href="./study.jsp?tagid=<%= tag.getId() %>"><%=tag.getKeyword() %></a>
					<%	  }
						}
					%>
		<br/><br/>
		<p>Please select a query:</p>
		<br/>
		<form action="./study.jsp" method="post">
		<select name="tagid">
		<% 	for(Tag tag: ContextBasedSearchEvaluation.tagsAsList){%>
			<option value="<%=tag.getId() %>"><%= tag.getKeyword() %></option>
				
			<%}
		%>
		</select>
		<button type="submit">go</button>
		</form>
		<% } %>
		<br/><br/><br/><br/>
		</div>
		<div id="sidebar_right">
			
		</div>
	</div>
	<div id="footer">
		<%@ include file="../jsp-includes/footer.jsp" %>
	</div>
</body>
</html>